package leetcode;

import java.util.Arrays;
import java.util.Scanner;

/**
 * ClassName: BaiduT2
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/9/2 19:31
 * @Version 1.0
 */
public class BaiduT2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- > 0) {
            int n = scanner.nextInt();
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextLong();
            }
            long[] b = new long[n];
            for (int i = 0; i < n; i++) {
                b[i] = arr[i] - (i + 1);
            }
            long[] sortedB = b.clone();
            Arrays.sort(sortedB);
            long count = 0;
            for (int i = 0; i < n; i++) {
               long target = -b[i];
               int left = i + 1;
               int right = n - 1;
               int pos = -1;
               while (left <= right){
                   int mid = left + (right - left) / 2;
                   if (sortedB[mid] > target) {
                       pos = mid;
                       right = mid - 1;
                   } else {
                       left = mid + 1;
                   }
               }
               if (pos != -1) {
                   count += (n-pos);
               }
            }
            System.out.println(count);
        }
        scanner.close();
    }
}
